<?php

namespace common\widgets\grid;

use yii\helpers\ArrayHelper;

/**
 * LabelColumn displays a column of mark text content in a grid view.
 *
 * @author emhome <emhome@163.com>
 * @since 2.0
 */
class OptionLabelColumn extends \yii\grid\DataColumn {

    public $format = 'raw';

    /**
     * Returns the data cell value.
     * @param mixed $model the data model
     * @param mixed $key the key associated with the data model
     * @param int $index the zero-based index of the data model among the models array returned by [[GridView::dataProvider]].
     * @return string the data cell value
     */
    public function getDataCellValue($model, $key, $index) {
        $options = $model->getOptionList($this->attribute);
        return ArrayHelper::getValue($options, $model->{$this->attribute});
    }

}
